home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #2
/
Amiga Plus CD - 2004 - No. 02.iso
/
AmiSoft
/
Util
/
conv
/
MIDI2asm.lha
/
MIDI2asm
/
fixmidi.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-08-22
|
1KB
|
34 lines
/* fix midifile V1.1 */
/* © by Stefan Haubenthal 1995/98
Usage: fixmidi file_to_fix
look for "t:file_to_fix" */
if ~arg() then say sourceline(3)
if ~open(oldfile,arg(1)) then exit 0
if ~open(newfile,"t:"arg(1),'W') then exit 10
ok=1
do track=0
magic=readch(oldfile,4)
if eof(oldfile) | magic~="MThd" & magic~="MTrk" then leave
len=c2d(readch(oldfile,4))
chunk=readch(oldfile,65535)
pos=pos("MTrk",chunk)-1
if pos=-1 then pos=length(chunk)
diff=pos-len
if diff~=0 then ok=0
if abs(diff)=1 then s=""
else s="s"
select
when diff=0 then say "Track "track" is okay"
when diff<0 then say "Track "track" is "||-diff" byte"s" too short"
when diff>0 then say "Track "track" is "diff" byte"s" too long"
end
call seek(oldfile,-(length(chunk)-pos))
/* call writech(newfile,magic||d2c(pos,4)substr(chunk,1,pos))*/
call writech(newfile,magic||d2c(len,4)substr(chunk,1,len))
end
call close(newfile)
address command
if ok then delete "22"x"t:"arg(1)"22"x
else filenote "22"x||arg(1)"22"x "corrupt"
if ~ok then exit 5